﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SanctusSoftware.Spelling
{
    public static class DictionaryManager
    {

        static DictionaryManager()
        {
            DictionaryManager.AddDictionary(new HunspellDictionary());
        }

        #region Manage Dictionaries

        private static readonly List<IDictionary> _Dictionaries = new List<IDictionary>();

        public static void AddDictionary(IDictionary dictionary)
        {
            if (_Dictionaries.Contains(dictionary))
            {
                throw new ArgumentException();
            }
            _Dictionaries.Add(dictionary);
        }

        public static void RemoveDictionary(IDictionary dictionary)
        {
            if (!_Dictionaries.Contains(dictionary))
            {
                throw new ArgumentException();
            }
            _Dictionaries.Remove(dictionary);
        }

        #endregion

        #region Spelling

        public static bool IsWordInDictionary(string word)
        {
            foreach (IDictionary dict in _Dictionaries)
            {
                if (dict.IsWordInDictionary(word))
                {
                    return true;
                }
            }
            return false;
        }

        #endregion

    }
}
